// Copyright (c) 2022, hzmes and contributors
// For license information, please see license.txt

frappe.ui.form.on('SRM Available Goods', {
	// 根据字表行记录的某个字段值限制下拉选择范围
	setup: function(frm) {
		// category_item子表中要限制的目标字段名, supplier_category子表在【主表】SRM Supplier中的字段名
		frm.set_query("material_group", "goods_sub", function(doc, cdt, cdn) {
			const row = locals[cdt][cdn];
			return {
				"filters": {
					'parent_srm_material_group': ""
				}
			};
		});
		frm.set_query("group_item", "goods_sub", function(doc, cdt, cdn) {
			const row = locals[cdt][cdn];
			return {
				"filters": {
					'parent_srm_material_group': row.material_group
				}
			};
		});
	},
});
